import { defineStore } from 'pinia';

export const usePTCRewireStore = defineStore('ptcRewire', {
  state: () => ({
    // 步骤状态
    stepOneCompleted: false,
    stepTwoCompleted: false,
    stepThreeCompleted: false,
    stepFourCompleted: false, // 新添加的重新接线步骤
    
    // 测量状态
    isMeasuring: false,
    
    // 当前测量的参数
    currentMeasurement: {
      value: null,
      type: null
    }
  }),
  
  getters: {
    // 获取步骤一状态
    getStepOneStatus: (state) => state.stepOneCompleted,
    
    // 获取步骤二状态
    getStepTwoStatus: (state) => state.stepTwoCompleted,
    
    // 获取步骤三状态（现在是重新接线步骤）
    getStepThreeStatus: (state) => state.stepThreeCompleted,
    
    // 获取步骤四状态（现在是查看温度曲线步骤）
    getStepFourStatus: (state) => state.stepFourCompleted,
    
    // 获取测量状态
    getIsMeasuring: (state) => state.isMeasuring,
    
    // 获取当前测量值
    getCurrentMeasurement: (state) => state.currentMeasurement
  },
  
  actions: {
    // 完成步骤一
    completeStepOne() {
      this.stepOneCompleted = true;
    },
    
    // 完成步骤二
    completeStepTwo() {
      this.stepTwoCompleted = true;
    },
    
    // 完成步骤三（重新接线）
    completeStepThree() {
      this.stepThreeCompleted = true;
    },
    
    // 完成步骤四（查看温度曲线）
    completeStepFour() {
      this.stepFourCompleted = true;
    },
    
    // 设置测量状态
    setMeasuringStatus(status) {
      this.isMeasuring = status;
    },
    
    // 设置当前测量值
    setCurrentMeasurement(value, type) {
      this.currentMeasurement = {
        value,
        type
      };
    },
    
    // 重置所有状态
    reset() {
      this.stepOneCompleted = false;
      this.stepTwoCompleted = false;
      this.stepThreeCompleted = false;
      this.stepFourCompleted = false;
      this.isMeasuring = false;
      this.currentMeasurement = {
        value: null,
        type: null
      };
    }
  }
});